<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="div1">
        <a href="#">a1</a><br>
        <a href="#">a2</a><br>
        <a href="#">a3</a><br>
        <a href="#">a4</a><br>
    </div>

    <button>点击添加一个a标签</button>

    <script>

        const div1 = document.getElementById('div1')

        // 代理绑定
        div1.addEventListener( 'click' , e => {
            e.preventDefault()
            const target = e.target
            if( target.nodeName === 'A' ){
                alert(target.innerHTML)
            }
        } )

        

    </script>
</body>
</html>